using System;
using Clandestine.Base;
using Clandestine.Graphics;

namespace Clandestine.Engines.Field
{
	public static class SpriteAutoDepthExtensions
	{
		public static void SetDepthAuto(this Sprite sprite)
		{
			sprite.PreRender += delegate()
			{
				// TODO: Deal with rotation???
				// sprite.Depth = maximum (i.e. visually lowest) Y coordinate
				decimal my = (decimal) (((sprite.UnscaledSize.Height - sprite.Transform.Origin.Y) * sprite.Transform.ScaleUniform
							* sprite.Transform.ScaleY) + sprite.Transform.Y);
				sprite.Depth = my;
			};
		}
	}
}

